//
//  AddressBook+.m
//  tabbar-test
//
//  Created by Arcticsun on 11-6-18.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "AddressBookAddition.h"


@implementation AddressBook_

+(NSNumber*) AddGroupWithName:(ABAddressBookRef)addressBook Name:(NSString *)name{
	CFErrorRef err = NULL;
	ABRecordRef newGroup = ABGroupCreate();
	ABRecordSetValue(newGroup, kABGroupNameProperty, name, &err);
	ABAddressBookAddRecord(addressBook, newGroup, &err);
	ABAddressBookSave(addressBook, &err);
	return [NSNumber numberWithInt:ABRecordGetRecordID(newGroup)];
}

+(void) DelGroupByID:(ABAddressBookRef)addressBook ID:(NSNumber*)groupID{
	CFErrorRef err = NULL;
	//		ABAddressBookRef address = ABAddressBookCreate();
	NSLog(@"gid=%@",groupID);
	ABRecordRef group = ABAddressBookGetGroupWithRecordID(addressBook, [groupID intValue]);
	ABAddressBookRemoveRecord(addressBook, group, &err);
	NSLog(@"Error:%@",err);
	ABAddressBookSave(addressBook, &err);
	NSLog(@"Error:%@",err);
}

@end
